'''
A database of platform specific variables.

CONFIG_DIR      - The user specific configuration directory.
USER_PLUGIN_DIR - The user specific plugin directory.
SHARED_PLUGIN_DIR - The plugin directory shared by all users.
CORE_PLUGIN_DIR     - The plugin directory used by plugins core to butler.
REGISTRY_PATH   - The saved file path for the user configuration database.

Butler will attempt to create all folders if they don't yet exist, however
that doesn't mean that it will succeed.

Currently supported platforms:
 - Linux

'''

import platform
import os
from os.path import *

HOME_DIR = expanduser("~")
SCRIPT_DIR = os.path.dirname(__file__)


#Default is linux (as this should also apply to unix/osx in a pinch
CONFIG_DIR = join(HOME_DIR, ".config", "butler")
USER_PLUGIN_DIR = join(CONFIG_DIR, "plugins")
SHARED_PLUGIN_DIR = join(SCRIPT_DIR, "butler_plugins")
CORE_PLUGIN_DIR = join(SCRIPT_DIR, "core_plugins")
REGISTRY_PATH = join(CONFIG_DIR, "registry")



if platform.system() == "Win32":
    pass



#Lists of plugin directories:
CORE_PLUGIN_LIST = [CORE_PLUGIN_DIR]
STANDARD_PLUGIN_LIST = [
                        USER_PLUGIN_DIR,
                        SHARED_PLUGIN_DIR,
                        ]



def mkdir(path):
    '''Makes a directory if possible and if it does not yet exist.'''
    if not os.path.exists(path):
        try:
            os.makedirs(path)
        except Exception:
            print("Warning, couldn't create directory: %s" % (path))
            pass

#Try making all of the directories.
mkdir(CONFIG_DIR)
mkdir(USER_PLUGIN_DIR)
mkdir(SHARED_PLUGIN_DIR)